package com.acme.bankapp.service.bank;

import com.acme.bankapp.domine.client.*;
import com.acme.bankapp.domine.bank.*;
import com.acme.bankapp.domine.account.*;
import com.acme.bankapp.exceptions.ClientExistsException;

import java.util.List;


public class BankService {

    public static Bank createNewBank() {
        return new Bank();
    }

    public static Bank createNewBank(final List<ClientRegistrationListener>
            clientRegistrationListenerList) {
        return new Bank(clientRegistrationListenerList);
    }


    public static void addClient(final Bank bank, final Client client)
            throws ClientExistsException {
        bank.addClient(client);
    }

    public static Client addClient(final Bank bank, final String name,
            final Gender gender) throws ClientExistsException {
        Client client = new Client(name, gender);
        bank.addClient(client);
        return client;
    }

    public static void printBalance(final Bank bank) {
        System.out.println("printBalance");
        for (Client client: bank.getClients()) {
            for (Account account: client.getAccounts()) {
                System.out.println(client.getClientSalutation() + " : "
                    + account.getType() + " : " + account.getBalance());
            }
        }
    }

    public static void printMaximumAmountToWithdraw(final Bank bank) {
        System.out.println("printMaximumAmountToWithdraw");
        for (Client client: bank.getClients()) {
            for (Account account: client.getAccounts()) {
                System.out.println(client.getClientSalutation() + " : "
                    + account.getType() + " : "
                    + account.maximumAmountToWithdraw());
            }
        }
    }
}
